const baseUrl = "http://www.elitestu.vip:28019/api/v1"; //公用路径

const ajaxFun = (url,method,data={}) => {
  return new Promise((reslove, reject) => {
    wx.request({
      url:baseUrl+url, //仅为示例，并非真实的接口地址
      method,
      data,
      header: {
        "token":wx.getStorageSync('token')
      },
      success(res) {
        if(res.data.resultCode===416){
          wx.reLaunch({
            url: '/userPackage/pages/login/login',
          })
        }
        if(res.data.resultCode===200){
          wx.showToast({
            title: '成功',
            icon:"none"

          })
        }else if(res.data.resultCode===500){
          wx.showToast({
            title: res.data.message,
            icon:"none"
          })
        }
       
        reslove(res.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}
export {ajaxFun}